package de.openkanban.client.ui.presenter;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;

import de.openkanban.client.ui.board.BoardView;
import de.openkanban.client.ui.footer.Footer;
import de.openkanban.client.util.RootPanel;
import de.openkanban.shared.dto.BoardDto;

/**
 * Callback that handles create Board Response
 */
public class CreateBoardRequestCallback implements RequestCallback {

	@Override
	public void onResponseReceived(Request request, Response response) {
		BoardView boardView = RootPanel.main.getBoard();
		Footer footer = RootPanel.main.getFooter();

		if (response.getStatusCode() == 200) {
			BoardDto boardDto = new BoardDto(response.getText());
			boardView.getWhiteBoardView().setBoardDto(boardDto);

			RootPanel.activateBoardEditMode(false);

			boardView.showNewActivityButton();
			boardView.enableNewActivityButton();

			footer.showBoardContactTileGrid();
		}
	}

	@Override
	public void onError(Request request, Throwable exception) {
	}

}
